<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('话题列表')" />
	<th:block th:include="include :: bootstrap-select-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								话题名称：<input type="text" name="topicName"/>
							</li>

							<li>
								审核状态：
								<select id="verifyState" name="verifyState" class="selectpicker show-tick "
										data-live-search="true" data-none-selected-text="请选择">
									<option></option>
									<option value="0" >待审核</option>
									<option value="1">发布</option>
									<option value="2">隐藏</option>
								</select>
							</li>


							<li>话题种类：<select id="topicType" name="topicType" class="selectpicker show-tick "
										   data-live-search="true" data-none-selected-text="请选择">
								<option></option>
								<option value="1" >普通话题</option>
								<option value="2">官方话题</option>
							</select>
							</li>

							<li class="select-time">
								<label>发起日期： </label>
								<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
								<span>-</span>
								<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm" id="toolbar" role="group">

				<a class="btn btn-danger btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="topic:topic:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
				<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="topic:topic:export">
						<i class="fa fa-download"></i> 导出
				 </a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
	<th:block th:include="include :: bootstrap-select-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('topic:topic:edit')}]];
        var removeFlag = [[${@permission.hasPermi('topic:topic:remove')}]];
        var prefix = ctx + "topic/topic";

        $(function() {
            var options = {
                url: prefix + "/verifyList",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                modalName: "话题",
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id', 
					title : '',
					visible: false
				},
					{
						field : 'topicName',
						title : '话题名称',
						sortable: true
					},
					{
						field : 'topicIntroduction',
						title : '话题简介',
						sortable: true
					},



					{
						title: '审核状态',
						formatter: function(value, row, index) {
							if(row.verifyState==0){
								return "待审核";
							} else if(row.verifyState==1){
								return "发布";
							} else if(row.verifyState==2){
								return "隐藏";
							}
						}
					},



					{
						title: '话题种类',
						formatter: function(value, row, index) {
							if(row.topicType==1){
								return "普通话题";
							} else if(row.topicType==2){
								return "官方话题";
							}
						}
					},
				{
					field : 'topicPostNum', 
					title : '话题帖子量',
					sortable: true
				},



				{
					field : 'createDate', 
					title : '发起日期',
					sortable: true
				},

		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
						actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="postUpdate(\'' + row.id + '\')"><i class="fa fa-edit"></i>查看详情</a> ');
						actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="getComplain(\'' + row.id + '\')"><i class="fa fa-edit"></i>举报情况</a> ');
						actions.push('<a class="btn btn-warning btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="ignoreVerify(\'' + row.id + '\')"><i class="fa fa-edit"></i>忽略举报</a> ');
						actions.push('<a class="btn btn-default btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="hideVerify(\'' + row.id + '\')"><i class="fa fa-edit"></i>隐藏动态</a> ');
						actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });

		function postUpdate(id) {
			var options = {
				title: "查看详情",
				width: 1300,
				height: 800,
				url: prefix + "/edit/" + id,
				skin: 'layui-layer-gray',
				btn: ['关闭'],
				yes: function (index, layero) {
					layer.close(index);
				}
			};
			$.modal.openOptions(options);
		}



		function postAdd() {
			$.modal.open('添加动态', prefix + "/add", '1300', '800');
		}

		function getComplain(id) {
			var options = {
				title: "举报情况",
				width: 1300,
				height: 800,
				url: prefix + "/getComplain/" + id,
				skin: 'layui-layer-gray',
				btn: ['关闭'],
				yes: function (index, layero) {
					layer.close(index);
				}
			};
			$.modal.openOptions(options);
		}

		function ignoreVerify(id) {
			$.modal.confirm("是否确认忽略举报？", function () {
				var url = prefix + "/ignoreVerify";
				var data = {"id": id};
				$.operate.submit(url, "post", "json", data);
				var buy = document.getElementById('listSearch');//给你的a标签加一个id :btnBuy
				buy.click();
			});
		}

		function hideVerify(id) {
			$.modal.confirm("是否确认隐藏该话题？", function () {
				var url = prefix + "/hideVerify";
				var data = {"id": id};
				$.operate.submit(url, "post", "json", data);
				var buy = document.getElementById('listSearch');//给你的a标签加一个id :btnBuy
				buy.click();
			});
		}
    </script>
</body>
</html>